package ru.algorithm.join;

import ru.algorithm.clusterization.cftree.CFTree;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * Yuri Zemlyanskiy <urikz@yandex-team.ru>
 * Date: 05.05.2011
 */
public class SimpleClusteringJoinAlgorithm extends DataStreamAlgorithm {

    final private CFTree tree;

    private static final int MAX_NODE_ENTRIES = 10;
    private static final double INITIAL_TRESHOLD = 0.5;
    private static final int DISTANCE_FUNCTION = CFTree.D0_DIST;
    private static final boolean APPLY_MERGING_REFINEMENT = false;

    public SimpleClusteringJoinAlgorithm() {
        tree = new CFTree(MAX_NODE_ENTRIES, INITIAL_TRESHOLD,
                DISTANCE_FUNCTION, APPLY_MERGING_REFINEMENT);
    }

    public void process(InputStream input, OutputStream output) {
        for (final double[] entry : read(input)) {
            tree.insertEntry(entry);
        }
    }
}
